package com.example.blog.common.utils;

import com.example.blog.common.pojo.dataobject.BlogInfo;
import com.example.blog.common.pojo.dataobject.UserInfo;
import com.example.blog.common.pojo.request.AddBlogParam;
import com.example.blog.common.pojo.request.UpBlogParam;
import com.example.blog.common.pojo.response.BlogInfoResponse;
import com.example.blog.common.pojo.response.UserInfoResponse;
import org.springframework.beans.BeanUtils;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2025/7/25
 * Time: 20:26
 */
public class BeanConverse {
    public static BlogInfoResponse trans(BlogInfo blogInfo) {
        BlogInfoResponse blogInfoResponse = new BlogInfoResponse();
        if (blogInfo != null) {
            BeanUtils.copyProperties(blogInfo, blogInfoResponse);
        }

        return blogInfoResponse;
    }

    public static UserInfoResponse trans(UserInfo userInfo) {
        UserInfoResponse userInfoResponse = new UserInfoResponse();
        if (userInfo != null) {
            BeanUtils.copyProperties(userInfo, userInfoResponse);
        }

        return userInfoResponse;
    }

    public static BlogInfo trans(AddBlogParam param) {
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(param, blogInfo);
        return blogInfo;
    }

    public static BlogInfo trans(UpBlogParam param) {
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(param, blogInfo);
        return blogInfo;
    }
}
